package com.framework;

import java.util.ArrayList;
import java.util.HashMap;

public class Result extends HashMap<String, Object> {

    public Result() {
        this.put( "result", Integer.valueOf( 1 ) );
    }


    public Object getErrormsg() {
        return this.get( "errorMsgs" );
    }

    public void addErrormsg(String errorMassage) {
        Object localObject = this.get( "errorMsgs" );

        this.put( "result", Integer.valueOf( 0 ) );

        if (localObject != null) {
            ArrayList<Object> errorMessageList = new ArrayList();
            errorMessageList.add( localObject );
            errorMessageList.add( localObject );
            this.put( "errorMsgs", errorMessageList );
        } else {
            this.put( "errorMsgs", errorMassage );
        }
    }

    public  int getResultCode(){
        return ((Integer)this.get( "result" )).intValue();
    }


    public  boolean isFail(){
        return  this.get( "errorMsgs" )!=null ? true : false;
    }
    public  boolean isSuccess(){
        return  this.get( "errorMsgs" )==null ? true : false;
    }

    public <T> void setReturnObj(T t) {
        this.put( "obj", t );
    }

    public Object getReturnObj() {
        Object obj = this.get( "obj" );
        return this.get( "obj" );
    }
}
